  <script type="text/javascript"><!--//--><![CDATA[//><!--

    $(document).ready(function() {


        // Setup Form
        $('#form_master').setupForm([
            { name: 'no_toko', type: 'text', size: 'short', readonly:true , maxlength: 10, },
            { name: 'lokasi_tempat', type: 'text', size: 'long', maxlength: 200, noempty:true },
            { name: 'luas_tempat', type: 'text', size: 'short', maxlength: 10, noempty:true },
            { name: 'harga_sewa', type: 'text', size: 'long', maxlength: 255, noempty:true },
            { name: 'status_sewa', type: 'text', size: 'long', maxlength: 255, noempty:true },
        ], <?php echo json_encode($data); ?>);
        
        <?php if (isset($no_tenant)) {
                ?>
                var no_tenant = "<?php echo $no_tenant; ?>";
                <?php
            }
        ?>
        
        $("#anggota-hide").hide();
        $("#anggota-hide2").hide();
        $("#pertokoan_belakang").hide();
        $("#tenant-hide").hide();
        $("#tenant-hide2").hide();
        $("#tenant-hide3").hide();
        
        <?php if($mode=="edit"){ ?>
        $('#no_tenant').readonly();
        <?php } ?>
        
        // Set Action Button
        var buttons = [{ label: 'Save', icon: 'save', onclick: function() { 
                            $('#form_master').submitForm(   '/'+controller+'/ajax_post'); 
                        }},
                       { label: 'Close', icon: 'cancel', onclick: function() { loadPage('/'+controller+'/Index'); } }];
        setAction(buttons);

        <?php if (isset($no_tenant)) {
                ?>
        $('#no_tenant').setval(no_tenant);
                <?php
            }
        ?>

        $("#status_anggota").change(function() {
             var str = "";
             $("#status_anggota option:selected").each(function() {
                str = $(this).text();
             });

             if(str == 'Anggota'){
                $("#anggota-hide").show();
                $("#anggota-hide2").show();
                $("#pertokoan_belakang").show();
             }
             else if(str == 'Bukan Anggota'){
                $("#anggota-hide").hide();
                $("#anggota-hide2").hide();
                $("#pertokoan_belakang").hide();
             }
             
        });

        $("#status_tenant").change(function() {
             var str = "";
             $("#status_tenant option:selected").each(function() {
                str = $(this).text();
             });

             if(str == 'Tenant'){
                $("#tenant-hide").show();
                $("#tenant-hide2").show();
                $("#tenant-hide3").show();
             }
             else if(str == 'Calon Penyewa'){
                $("#tenant-hide").hide();
                $("#tenant-hide2").hide();
                $("#tenant-hide3").hide();
             }
             
        });

        // Create Tab
        $('#tt').tabs({ border:false });  
        
        // Focus at First Object
        $('#form_master').focusFirst();

    });




//--><!]]></script>

<div id="form_master_message" style="display:none;"></div>
    <table class="tb_form" style="width:100%;" cellpadding="0" cellspacing="0">
    <tr>
        <td class="label" style="width:150px">No Tenant</td>
        <td><input id="no_tenant" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Nama Tenant</td>
        <td><input id="nama_tenant" /></td>
    </tr>    
    <tr>
        <td class="label" style="width:150px">No Toko</td>
        <td><input id="no_toko" /></td>
    </tr>    
    <tr>
        <td class="label" style="width:150px">Jenis Usaha</td>
        <td><input id="jenis_usaha" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Lokasi Tempat</td>
        <td>  <select id="lokasi_tempat" name="lokasi_tempat">
                <option value="Counter Lantai 1">Counter Lantai 1</option>
                <option value="Counter Lantai 2">Counter Lantai 2</option>
                <option value="Pertokooan Lantai 2">Pertokooan Lantai 2</option>
                <option value="Pertokooan Belakang" id="pertokoan_belakang">Pertokooan Belakang</option>
                <option value="Pujasera">Pujasera</option>
            </select></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Jenis Produk</td>
        <td><input id="jenis_produk" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Alamat Lengkap</td>
        <td><textarea id="alamat_lengkap" name="alamat_lengkap" rows="5" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">No Telephone</td>
        <td><input id="no_telephone" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">No Handphone</td>
        <td><input id="no_handphone" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Status Anggota</td>
        <td>
            <select id="status_anggota" name="status_anggota">
                <option value="Bukan Anggota">Bukan Anggota</option>
                <option value="Anggota">Anggota</option>
            </select>
        </td>
    </tr>
    <tr id="anggota-hide">
        <td class="label" style="width:150px">No Anggota</td>
        <td><input id="no_anggota" /></td>
    </tr>
    <tr id="anggota-hide2">
        <td class="label" style="width:150px">No ID Card</td>
        <td><input id="no_id_card" /></td>
    </tr>
    <tr>
        <td class="label" style="width:150px">Status Tenant</td>
        <td>
            <select id="status_tenant" name="status_tenant">
                <option value="Calon Penyewa">Calon Penyewa</option>
                <option value="Tenant">Tenant</option>
            </select>
        </td>
    </tr>
    <tr id="tenant-hide">
        <td class="label" style="width:150px">No Kontrak</td>
        <td><input id="no_kontrak" /></td>
    </tr>
    <tr id="tenant-hide2">
        <td class="label" style="width:150px">Harga Sewa</td>
        <td><input id="harga_sewa" /></td>
    </tr>
    <tr id="tenant-hide3">
        <td class="label" style="width:150px">Keterangan</td>
        <td><textarea id="keterangan" name="keterangan" /></td>
    </tr>  
</table>
